﻿FlyTalk.views.SearchView = Ext.extend(Ext.Panel, {
	scroll: false,
    indicator: true,
    fullscreen: true,
    layout: 'card', 	

	// tabBar:{
        // dock: 'bottom', // will put the menu on the bottom of the screen
		// layout:{
			// type: 'hbox',
			// pack: 'center' // this will center the menu
        // },		
    // },


    initComponent: function () {
		var direction = 'left'
    	Ext.apply(FlyTalk.views, {
    		SearchPostView: new FlyTalk.views.SearchPostView(),
    		SearchMapTab: new FlyTalk.views.SearchMapTab(),
			OfficialView: new FlyTalk.views.OfficialView(),
        });

		this.backButton = new Ext.Button({
			text: 'Back',
			ui: 'back',
			handler: this.backButtonTap,
			scope: this
		});
		
		this.toolbar = new Ext.Toolbar({
			title: 'Italian Restaurant',
			doc: 'top',
			layout: 'hbox',
			items: [
			    this.backButton,
				{xtype: 'spacer'},
				//this.composeButton,
			]
		});
		
		this.search = new Ext.Panel({
			html:"<img src='images/searchbox.png'>",
			height: 49,
//			style: "margin-bottom: 0em;padding-bottom: 0em;",
		});
		
		buttonsGroup2 = new Ext.SegmentedButton({ 
			xtype: 'segmentedbutton',
			//id: 'helpOutTabButtons',
			allowDepress: false,
			items: [{
				text: 'Official',
				
				//handler: this.backButtonTap,FlyTalk.views.ServicesTabAllView, 
				handler: function () {
					FlyTalk.views.SearchView.setActiveItem(FlyTalk.views.OfficialView, {type: 'slide', direction: 'right'});	
					direction = 'left';
				},
				pressed: true
			}, {
				text: 'Feeds',
				padding: '0 20 0 20',
				//handler: this.backButtonTap
				handler: function () {
					//FlyTalk.views.HelpOutView.setActiveItem(FlyTalk.views.HelpOutTabReviewView);
					console.log(direction)
					if (direction == 'left'){
						FlyTalk.views.SearchView.setActiveItem(FlyTalk.views.SearchPostView,{type: 'slide', direction: 'left'});
					} else {
						FlyTalk.views.SearchView.setActiveItem(FlyTalk.views.SearchPostView,{type: 'slide', direction: 'right'});
					}
					
				},
			}, {
				text: 'Map',
				padding: '0 20 0 20',
				//handler: this.backButtonTap
				handler: function () {
					FlyTalk.views.SearchView.setActiveItem(FlyTalk.views.SearchMapTab, {type: 'slide', direction: 'left'});
					direction = 'right';
				},
			}]
		});
		
		this.toolbartab = new Ext.Toolbar({
			//title: 'Services',
			doc: 'top',
			layout: 'hbox',
			ui: 'toptab',
			items: [
				{xtype: 'spacer'},
			    buttonsGroup2,
				{xtype: 'spacer'},
		
			]
		});
		
		this.dockedItems = [this.toolbar,this.search,this.toolbartab];

		this.items = [
		    FlyTalk.views.OfficialView, 
			FlyTalk.views.SearchPostView, 
			FlyTalk.views.SearchMapTab, 
		];
		FlyTalk.views.SearchMapTab.doComponentLayout();
		FlyTalk.views.SearchView.superclass.initComponent.call(this);
        
    },
    
	//home button
    backButtonTap: function () {
    	FlyTalk.views.mainView.setActiveItem(FlyTalk.views.SearchSearchView, {type: 'slide', direction: 'right'});
    },

});